package com.psp.web.persist.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.psp.web.model.CommentBean;
import com.psp.web.persist.dao.CommentDao;

@Repository
public class CommentImpl extends BaseImpl implements CommentDao {

	protected static final String NAME_SPACE = NAME_SPACE_HEADER + ".CommentMapper";

	@Override
	public List<CommentBean> selectByOid(String oid) {
		return sqlSessionTemplate.selectList(NAME_SPACE + ".selectByOid", oid);
	}

	@Override
	public CommentBean selectById(String id) {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectById", id);
	}

	@Override
	public int selectBsCount(String pid) {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectBsCount", pid);
	}

	@Override
	public List<CommentBean> selectBsList(int page, int pageSize, String pid) {
		Map<String, Object> where = new HashMap<>();
		where.put("start", page * pageSize);
		where.put("length", pageSize);
		where.put("pid", pid);
		return sqlSessionTemplate.selectList(NAME_SPACE + ".selectBsList", where);
	}

}
